import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '班级',
    align:"center",
    dataIndex: 'deptId_dictText'
   },
   {
    title: '房间',
    align:"center",
    dataIndex: 'roomId_dictText'
   },
   {
    title: '打分日期',
    align:"center",
    dataIndex: 'scoreDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '总分',
    align:"center",
    dataIndex: 'totalScore'
   },
   {
    title: '午休纪律得分',
    align:"center",
    dataIndex: 'noonScore'
   },
   {
    title: '晚寝纪律得分',
    align:"center",
    dataIndex: 'nightScore'
   },
   {
    title: '卫生得分',
    align:"center",
    dataIndex: 'healthScore'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "班级",
      field: "deptId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"sys_depart,depart_name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "房间",
      field: "roomId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dorm_room,room_code,id"
      },
      //colProps: {span: 6},
 	},
     {
      label: "打分日期",
      field: "scoreDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '班级',
    field: 'deptId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sys_depart,depart_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入班级!'},
          ];
     },
  },
  {
    label: '房间',
    field: 'roomId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dorm_room,room_code,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入房间!'},
          ];
     },
  },
  {
    label: '打分日期',
    field: 'scoreDate',
    component: 'DatePicker',
  },
  {
    label: '卫生得分',
    field: 'healthScore',
    component: 'InputNumber',
    dynamicDisabled:true
  },
  {
    label: '午休纪律得分',
    field: 'noonScore',
    component: 'InputNumber',
  },
  {
    label: '晚寝纪律得分',
    field: 'nightScore',
    component: 'InputNumber',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const dormScoreHealthColumns: JVxeColumn[] = [
    {
      title: '打分项',
      key: 'itemName',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '得分',
      key: 'score',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '打分项备注',
      key: 'itemRemark',
      type: JVxeTypes.textarea,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  deptId: {title: '班级',order: 0,view: 'list', type: 'string',dictTable: 'sys_depart', dictCode: 'id', dictText: 'depart_name',},
  roomId: {title: '房间',order: 1,view: 'number', type: 'number',dictTable: 'dorm_room', dictCode: 'id', dictText: 'room_code',},
  scoreDate: {title: '打分日期',order: 2,view: 'date', type: 'string',},
  healthScore: {title: '卫生得分',order: 3,view: 'number', type: 'number',},
  noonScore: {title: '午休纪律得分',order: 4,view: 'number', type: 'number',},
  nightScore: {title: '晚寝纪律得分',order: 5,view: 'number', type: 'number',},
  //子表高级查询
  dormScoreHealth: {
    title: '宿舍日打分内务卫生明细',
    view: 'table',
    fields: {
        itemId: {title: '打分项',order: 0,view: 'number', type: 'number',dictTable: 'dorm_health_item', dictCode: 'id', dictText: 'item_name',},
        score: {title: '得分',order: 1,view: 'number', type: 'number',},
        itemRemark: {title: '打分项备注',order: 2,view: 'textarea', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}

export const scoreColumns: BasicColumn[] = [
  {
   title: '扣分项',
   align:"center",
   dataIndex: 'itemName'
  },
  {
   title: '得分',
   align:"center",
   dataIndex: 'score'
  },
  {
   title: '备注',
   align:"center",
   dataIndex: 'itemRemark'
  },
];
export const allScoreColumns: BasicColumn[] = [
  {
   title: '打分项名称',
   align:"center",
   dataIndex: 'itemName'
  },
  {
   title: '分数',
   align:"center",
   dataIndex: 'itemScore'
  },
  {
   title: '打分项说明',
   align:"center",
   dataIndex: 'itemDesc'
  },
];
//查询数据
export const scoreSearchFormSchema: FormSchema[] = [
 {
     label: "打分项名称",
     field: 'itemName',
     component: 'Input',
     colProps: {span: 8},
  },
 {
     label: "打分项说明",
     field: 'itemDesc',
     component: 'Input',
     colProps: {span: 8},
  },
];